<script setup lang="ts">
import {ref} from "vue";
import {application} from "@/api/more";
import type {ApplicationPortal} from "@/api/more/model/indel";
import {personalInfomation} from "@/api/person/person";

const value = ref([]);
// url: 'https://fastly.jsdelivr.net/npm/@vant/assets/leaf.jpeg'
const num =Math.floor(Math.random() * 100000)
const username = ref<any>('');
const telephone = ref<any>('');
const Company = ref<any>('');
const message = ref<any>('');
const num2 = Math.floor(Math.random() * 100000)

function submit(){
    let id = ref<ApplicationPortal>({
        applicationId:num,
        invitee:username.value,
        inviteePhone:telephone.value,
        company:Company.value,
        companyIntro:message.value,
        createdBy:num2
    })
    application(id.value).then(result=>{
        console.log(result)
        username.value = ''
        telephone.value = ''
        Company.value = ''
        message.value = ''
    })
}

</script>

<template>
    <div>
        <div class="main">
            <van-form>
                <!--                <div>-->
                <van-cell-group inset>
                    <van-field
                            v-model="username"
                            name="人员姓名"
                            label="人员姓名"
                            placeholder="请输入申请人姓名"
                            :rules="[{ required: true, message: '请输入申请人姓名' }]"
                    ></van-field>
                    <van-field
                            v-model="telephone"
                            type="text"
                            name="联系方式"
                            label="联系方式"
                            placeholder="请输入联系方式"
                            :rules="[{ required: true, message: '请输入联系方式' }]"
                    />
                    <van-field
                            v-model="Company"
                            type="text"
                            name="公司名称"
                            label="公司名称"
                            placeholder="请输入公司名称"
                            :rules="[{ required: true, message: '请输入公司名称' }]"
                    />
                    <van-field
                            name="uploader"
                            label="营业执照"
                            :rules="[{ required: true, message: '请添加图片' }]"
                    >
                        <template #input>
                            <van-uploader v-model="value" :rules="[{ required: true, message: '请输入公司简介' }]"/>
                        </template>
                    </van-field>
                    <van-field
                            class="bg"
                            v-model="message"
                            rows="1"
                            autosize
                            type="textarea"
                            maxlength="300"
                            placeholder="请输入留言"
                            :rules="[{ required: true, message: '请输入留言' }]"
                    />
                </van-cell-group>

                <!--                <label for="">营业执照</label>-->
                <!--                <van-cell-group inset class="picLocation">-->
                <!--                    <van-field name="uploader">-->
                <!--                        <template #input>-->
                <!--                            <van-uploader v-model="value" :rules="[{ required: true, message: '请输入公司名称' }]"/>-->
                <!--                        </template>-->
                <!--                    </van-field>-->
                <!--                </van-cell-group>-->

                <!--                <label for="">留言</label>-->
                <!--                <van-cell-group inset>-->
                <!--                    <van-field-->
                <!--                        class="bg"-->
                <!--                        v-model="message"-->
                <!--                        rows="2"-->
                <!--                        autosize-->
                <!--                        type="textarea"-->
                <!--                        maxlength="1500"-->
                <!--                        placeholder="请输入留言"-->
                <!--                        show-word-limit-->
                <!--                        :rules="[{ required: true, message: '请输入留言' }]"-->
                <!--                    />-->
                <!--                </van-cell-group>-->
                <div style="margin: 16px;">
                    <van-button round block type="primary" native-type="submit" @click="submit">
                        提交
                    </van-button>
                </div>
            </van-form>
        </div>
    </div>
</template>

<style scoped lang="less">
.bg{
  background-color: #f7f8fa;
}
.main{
  width: 350px;
  //height: 530px;
  margin: 20px auto;
  border-radius: 5px;
  background-color: white;
  .theNameOfThePerson{
    height: 50px;
    line-height: 50px;
    border-bottom: 1px solid gainsboro;
    input{
      height: 40px;
      border-style: none;
      margin-left: 20px;
    }
  }
  .License{
    height: 160px;
    .picLocation{
      margin-left: 15px;
    }
  }
}
.footer{
  height: 40px;
  margin-top: 30px;
  background-color: #c81127;
}
label{
  margin-left: 30px;
}
</style>